/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ecfdb;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author SIDALI
 */
@Entity
@Table(name = "legumes_depot", catalog = "mandataire", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "LegumesDepot.findAll", query = "SELECT l FROM LegumesDepot l"),
    @NamedQuery(name = "LegumesDepot.findByIdlegumesDepot", query = "SELECT l FROM LegumesDepot l WHERE l.idlegumesDepot = :idlegumesDepot"),
    @NamedQuery(name = "LegumesDepot.findByQuantite", query = "SELECT l FROM LegumesDepot l WHERE l.quantite = :quantite")})
public class LegumesDepot implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idlegumes_depot", nullable = false)
    private Integer idlegumesDepot;
    @Column(name = "quantite")
    private Integer quantite;
    @OneToMany(mappedBy = "depot")
    private List<Vente> venteList;
    @JoinColumn(name = "depot", referencedColumnName = "iddepot")
    @ManyToOne
    private Depot depot;
    @JoinColumn(name = "legumes", referencedColumnName = "idlegumes")
    @ManyToOne
    private Legumes legumes;

    public LegumesDepot() {
    }

    public LegumesDepot(Integer idlegumesDepot) {
        this.idlegumesDepot = idlegumesDepot;
    }

    public Integer getIdlegumesDepot() {
        return idlegumesDepot;
    }

    public void setIdlegumesDepot(Integer idlegumesDepot) {
        this.idlegumesDepot = idlegumesDepot;
    }

    public Integer getQuantite() {
        return quantite;
    }

    public void setQuantite(Integer quantite) {
        this.quantite = quantite;
    }

    @XmlTransient
    public List<Vente> getVenteList() {
        return venteList;
    }

    public void setVenteList(List<Vente> venteList) {
        this.venteList = venteList;
    }

    public Depot getDepot() {
        return depot;
    }

    public void setDepot(Depot depot) {
        this.depot = depot;
    }

    public Legumes getLegumes() {
        return legumes;
    }

    public void setLegumes(Legumes legumes) {
        this.legumes = legumes;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idlegumesDepot != null ? idlegumesDepot.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof LegumesDepot)) {
            return false;
        }
        LegumesDepot other = (LegumesDepot) object;
        if ((this.idlegumesDepot == null && other.idlegumesDepot != null) || (this.idlegumesDepot != null && !this.idlegumesDepot.equals(other.idlegumesDepot))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return getLegumes() + " " + getQuantite();
    }
    
}
